﻿/* ==============================================================================
 * 功能描述：DDOLSingleton  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/3 23:39:15
 * ==============================================================================*/
using UnityEngine;
using System.Collections;

namespace ZZQFrameWork
{
    public class DDOLSingleton<T> : MonoBehaviour where T : Component
    {
        private static T _instance;

        public static T Instance
        {
            get
            {
                if (_instance ==null)
                {
                    GameObject go = GameObject.Find("DDOLGameObject");
                    if (go == null)
                    {
                        go = new GameObject("DDOLGameObject");
                        DontDestroyOnLoad(go);
                    }
                    _instance = go.AddComponent<T>();
                }
                return _instance;
            }
            set { _instance = value; }
        }
    }
}